# 环境默认default
cd yolov5_js
pip install -r requirements.txt
mkdir /project/.config/Ultralytics
mv ./Arial.ttf /project/.config/Ultralytics
echo "yolov5 done"

# --------------- Download file ------------------------
mkdir /project/train/weights
cd /project/train/weights
wget https://minio.cvmart.net/user-file/24082/793059ae4a024f12aad6caeac7e21828.pt   # n.pt
mv 793059ae4a024f12aad6caeac7e21828.pt yolov5n.pt
wget https://minio.cvmart.net/user-file/24082/72db0b47c24847fc8bc493a45a96b9b9.pt   # s.pt
mv 72db0b47c24847fc8bc493a45a96b9b9.pt yolov5s.pt
cd /project
wget https://minio.cvmart.net/user-file/24082/15c863bbe6514135b4e5acf1db884b2a.gz   # Tensorrt-6.0.1.5
echo "download done"

# ---------------- Tensorrt ----------------------------
tar xzvf 15c863bbe6514135b4e5acf1db884b2a.gz
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/project/TensorRT-6.0.1.5/lib

cd /project/TensorRT-6.0.1.5/python
pip install tensorrt-6.0.1.5-cp36-none-linux_x86_64.whl  # 根据自己的python版本选择相应的whl文件

# 安装UFF,支持tensorflow模型转化
# cd TensorRT-6.0.1.5/uff
# pip install uff-0.6.5-py2.py3-none-any.whl

# 安装graphsurgeon，支持自定义结构
cd /project/TensorRT-6.0.1.5/graphsurgeon
pip install graphsurgeon-0.4.1-py2.py3-none-any.whl

# 复制TensorRT路径下/lib、/include文件夹到对应系统文件夹（非必须，如果需要使用TensorRT进行编译，这一步是必须的）
sudo cp -r /project/TensorRT-6.0.1.5/lib/* /usr/lib             # 在TensorRT-6.0.1.5路径下执行
sudo cp -r /project/TensorRT-6.0.1.5/include/* /usr/include     # 在TensorRT-6.0.1.5路径下执行
echo "Tensorrt done"

# ------------------- tensorrtx ------------------
pip install pycuda
cd /project
git clone git://github.com/wang-xinyu/tensorrtx.git
cd /project/tensorrtx/yolov5
mkdir build
cd build
cmake ..
make
